package com.ruoyi.his.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.his.mapper.MedicalOrderMapper;
import com.ruoyi.his.domain.MedicalOrder;
import com.ruoyi.his.service.IMedicalOrderService;

/**
 * 医嘱信息Service业务层处理
 * 
 * @author hzr
 * @date 2024-10-18
 */
@Service
public class MedicalOrderServiceImpl implements IMedicalOrderService 
{
    @Autowired
    private MedicalOrderMapper medicalOrderMapper;

    /**
     * 查询医嘱信息
     * 
     * @param id 医嘱信息主键
     * @return 医嘱信息
     */
    @Override
    public MedicalOrder selectMedicalOrderById(Long id)
    {
        return medicalOrderMapper.selectMedicalOrderById(id);
    }

    /**
     * 查询医嘱信息列表
     * 
     * @param medicalOrder 医嘱信息
     * @return 医嘱信息
     */
    @Override
    public List<MedicalOrder> selectMedicalOrderList(MedicalOrder medicalOrder)
    {
        return medicalOrderMapper.selectMedicalOrderList(medicalOrder);
    }

    /**
     * 新增医嘱信息
     * 
     * @param medicalOrder 医嘱信息
     * @return 结果
     */
    @Override
    public int insertMedicalOrder(MedicalOrder medicalOrder)
    {
        return medicalOrderMapper.insertMedicalOrder(medicalOrder);
    }

    /**
     * 修改医嘱信息
     * 
     * @param medicalOrder 医嘱信息
     * @return 结果
     */
    @Override
    public int updateMedicalOrder(MedicalOrder medicalOrder)
    {
        return medicalOrderMapper.updateMedicalOrder(medicalOrder);
    }

    /**
     * 批量删除医嘱信息
     * 
     * @param ids 需要删除的医嘱信息主键
     * @return 结果
     */
    @Override
    public int deleteMedicalOrderByIds(Long[] ids)
    {
        return medicalOrderMapper.deleteMedicalOrderByIds(ids);
    }

    /**
     * 删除医嘱信息信息
     * 
     * @param id 医嘱信息主键
     * @return 结果
     */
    @Override
    public int deleteMedicalOrderById(Long id)
    {
        return medicalOrderMapper.deleteMedicalOrderById(id);
    }

    @Override
    public void updateOrderStatusToExecuted(Long orderId) {
        MedicalOrder order = medicalOrderMapper.selectMedicalOrderById(orderId);
        order.setStatus("1"); // 1表示已完成
        medicalOrderMapper.updateMedicalOrder(order);
    }

}
